package com.blueseaapps;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;

import com.blueseaapps.data.QuizQuestionData;
import com.blueseaapps.utility.QuestionDataGenerator;

public class QuestionManager {

	private static QuestionManager qmInstance;

	private int currPhotoId = 0;

	private List<QuizQuestionData> questions = new ArrayList<QuizQuestionData>();

	private QuestionManager(String selCategory, Context cxt) throws IOException {
		questions = QuestionDataGenerator.populateData(selCategory, cxt);
	}

	public static QuestionManager getInstance(String selCategory, Context cxt) throws IOException{
		if(qmInstance == null){
			qmInstance = new QuestionManager(selCategory, cxt);
		}
		return qmInstance;
	}

	public QuizQuestionData getNextQuestion(){
		QuizQuestionData nxtQuestion = null;
		if(currPhotoId < (questions.size())){
			nxtQuestion = questions.get(currPhotoId);
			currPhotoId++;
		}
		return nxtQuestion;
	}
	
	public int getTotalQuestions(){
		return questions.size();
	}
	
	public void resetQuestions(){
		qmInstance = null;
		currPhotoId = 0;
	}

}
